package com.pyue.eam.app.controller;

import com.pyue.eam.app.api.entity.AppPageEntity;
import com.pyue.eam.app.service.AppIndexService;
import com.pyue.eam.common.core.util.R;
import com.pyue.eam.common.security.annotation.Inner;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpHeaders;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * app 首页控制
 *
 * @author eam
 * @date 2023/6/8
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/index")
@Tag(description = "App 页面控制", name = "app index")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class AppIndexController {

    private final AppIndexService indexService;

    /**
     * 首页
     *
     * @return Object
     */
    @Inner(value = false)
    @GetMapping("/index")
    public R index() {
        Map<String, Object> detail = indexService.index();
        return R.ok(detail);
    }

    /**
     * 个人中心-设置页-首页-客服信息
     */
    // @Inner(value = false)
    @GetMapping("/decorate")
    public R decorate(@Validated @RequestParam("id") Integer id) {
        AppPageEntity detail = indexService.decorate(id);
        return R.ok(detail);
    }

    /**
     * 底部导航
     */
    // @Inner(value = false)
    @GetMapping({"/config/{flag}"})
    public R config(@PathVariable String flag) {
        Map<String, Object> map = indexService.config(flag);
        return R.ok(map);
    }

}
